export default {
    created() {
        this.massmarks = new AMap.MassMarks([], {
            opacity: 1,
            zIndex: 105,
            alwaysRender: true,
            style: {
                anchor: new AMap.Pixel(5, 5),
                url: require("../../../assets/image/a.png"),
                size: new AMap.Size(15, 15),
                // size: new AMap.Size(50, 50),
            },
            bubble: true
        });
    },
    mounted() {
        this.massmarks.setMap(this.map);
        this.addOpenInfoWindow();
    },
    methods: {
        // ----------------- 功能 -------------

        /**
         * 设置点数据
         * @param val
         */
        setMassData(val) {
            let Masslist=[];
            for (let i = 0; i < val.length; i++) {
                if (val[i] !== undefined) {
                    Masslist.push(val[i])
                }

            }
            this.massmarks.setData(Masslist);
        },

        // ---------------- 事件 ---------------
        /**
         * 添加信息窗口
         */
        addOpenInfoWindow() {
            let that = this;
            this.massmarks.on("mouseover", e => {
                let infoWindow;
                infoWindow = that.addInfoWindow("黑广播", e.data, "broad")
                infoWindow.open(that.map, e.data.lnglat);
            });
            this.massmarks.on("mouseout", () => {
                that.closeInfoWindow();
            });
        }
    }
}